package edu.ts.crowdfunding.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import edu.ts.crowdfunding.domain.User;
import edu.ts.crowdfunding.service.UserService;
import edu.ts.crowdfunding.utils.Result;
import edu.ts.crowdfunding.vo.UserRegisterVo;
import edu.ts.crowdfunding.vo.UserVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/user")
@Tag(name = "用户接口", description = "用户相关接口")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    @Operation(summary = "用户登录接口", description = "返回登录结果  1:成功 0:失败")
    public Result login(@RequestBody UserVo userVo) {
        return userService.login(userVo);
    }

    @PostMapping("/register")
    @Operation(summary = "用户注册接口", description = "返回注册结果  1:成功 0:失败")
    public Result register(@RequestBody UserRegisterVo user) {
        return userService.register(user);
    }

    @GetMapping("/list")
    @Operation(summary = "用户列表接口", description = "1:成功 0:失败")
    public Result list() {
        return userService.listUsers();
    }
}
